<template>
	<div id="home">
		<ul class="mui-table-view">
			<li class="mui-table-view-cell mui-media" v-for="(item,index) in list" :key='index'>
				<router-link v-bind="{to:'/news/newsshow/'+item.id}">
					<img class="mui-media-object mui-pull-left" :src="item.img_url">
					<div class="mui-media-body">
						{{item.title}}
						<p class='mui-ellipsis'>{{item.zhaiyao}}</p>
						<p><span class="left">发表时间：{{item.add_time | datefmt('YYYY-MM-DD HH:mm:ss')}}</span><span class="right">点击数：{{item.click}}</span></p>
					</div>
				</router-link>
			</li>
		</ul>
	</div>
</template>

<script>
	import { Toast } from 'mint-ui';
	export default {
		data() {
			return {
				list: []
			}
		},
		created() {
			this.getNewsLists();
		},
		methods: {
			getNewsLists() {
				this.$http.get(this.$common.domain + '/api/getnewslist').then(function(res) {
					if(res.body.status != 0) {
						Toast({
							message: res.body.message,
							position: 'bottom',
							duration: 5000
						});
						return;
					}
					this.list = res.body.message;
				});
			}
		}
	}
</script>

<style scoped>
	.mui-table-view img {
		width: 80px;
		height: 80px;
		line-height: 80px;
		max-width: 80px;
	}
	
	.mui-media-body>p:last-of-type {
		color: deepskyblue;
		margin-top: 20px;
	}
	
	.mui-media-body>p:last-of-type>span:first-of-type {
		margin-right: 20px;
	}
</style>